//
// Created by ts on 2023/5/10.
//

#ifndef LEARN_VULKAN_VKBUNDLE_H
#define LEARN_VULKAN_VKBUNDLE_H

#include "Headers.h"

struct SwapchainParam{
    VkSurfaceCapabilitiesKHR capabilities;
    VkSurfaceFormatKHR format;
    VkPresentModeKHR presentMode;
    VkExtent2D extent;
    VkFormat depthFormat;
    VkSampleCountFlagBits maxSampleCount;
};

struct SwapchainImage{
    uint32_t imageCount;
    VkImage *images;
    VkImageView *views;
};

struct DeviceInfo {
    VkPhysicalDevice physicalDev;
    VkPhysicalDeviceLimits physicalDevLimits;
    VkPhysicalDeviceMemoryProperties physicalDevMemoProps;
    VkDevice device;
};

struct QueueInfo {
    uint16_t workQueueIndex;
    uint16_t presentQueueIndex;
    VkQueue queue;
};

struct VkBundle {
    VkInstance instance;
    VkDebugReportCallbackEXT debugReport;

    VkSurfaceKHR surface;
    struct DeviceInfo deviceInfo;
    struct QueueInfo queueInfo;

    SwapchainParam swapchainParam;
    VkSwapchainKHR swapchain;
    SwapchainImage swapchainImage;

    VkImage depthImage;
    VkDeviceMemory depthImageMemory;
    VkImageView depthImageView;
    VkSampler depthImageSampler;

    VkRenderPass renderPass;
    VkPipelineCache pipelineCache;
    VkPipelineLayout pipelineLayout;
    VkShaderModule vertexShaderModule;
    VkShaderModule fragShaderModule;
    VkPipeline graphicPipeline;

    uint32_t framebufferCount;
    VkFramebuffer *framebuffers;
    VkCommandPool cmdPool;
    uint32_t cmdBufferCount;
    VkCommandBuffer *cmdBuffers;

    uint32_t maxFrameCount;
    VkSemaphore *imageSemaphores;
    VkSemaphore *presentSemaphores;
    VkFence *fences;

    VkDescriptorSetLayout descriptorSetLayout;
    VkDescriptorPool descriptorPool;
    VkDescriptorSet *descriptorSets;

    VkImage colorImage;
    VkDeviceMemory colorImageMemory;
    VkImageView colorImageView;
};

#endif //LEARN_VULKAN_VKBUNDLE_H
